using System;
using PluginScheduler.Jobs;

namespace PluginScheduler.Interfaces
{
    public interface ITrigger : ICloneable, IComparable<ITrigger>
    {
        string Key { set; get; }

        /// <summary>
        /// Get or set the description given to the <see cref="ITrigger" /> instance by
        /// its creator (if any).
        /// </summary>
        string Description { get; set; }

        /// <summary>
        /// Get or set the <see cref="JobDataMap" /> that is associated with the 
        /// <see cref="ITrigger" />.
        /// <para>
        /// Changes made to this map during job execution are not re-persisted, and
        /// in fact typically result in an illegal state.
        /// </para>
        /// </summary>
        JobDataMap JobDataMap { get; set; }

        /// <summary>
        /// Returns the last time at which the <see cref="ITrigger" /> will fire, if
        /// the Trigger will repeat indefinitely, null will be returned.
        /// <para>
        /// Note that the return time *may* be in the past.
        /// </para>
        /// </summary>
        DateTimeOffset? FinalFireTime { get; set; }

        /// <summary>
        /// Gets and sets the date/time on which the trigger must stop firing. This 
        /// defines the final boundary for trigger firings &#x8212; the trigger will
        /// not fire after to this date and time. If this value is null, no end time
        /// boundary is assumed, and the trigger can continue indefinitely.
        /// </summary>
        DateTimeOffset? EndTime { get; set; }

        DateTimeOffset StartTime { get; set; }

        DateTimeOffset? GetNextFireTime();

        DateTimeOffset? GetPreviousFireTime();

        JobKey JobKey { get; set; }
        
        void Validate();

        DateTimeOffset? ComputeFirstFireTime();
    }
}